package ren.nearby.http.permission;

import android.view.View;
import android.view.ViewGroup;



import java.util.ArrayList;
import java.util.List;

import ren.nearby.http.R;
import ren.nearby.http.adapter.base.BaseRecyclerViewAdapter;

/**
 * Created by Administrator on 2016/4/19.
 */
public class PermissionAdapter extends BaseRecyclerViewAdapter<PermissionBean, PermissionAdapter.IndexViewHolder> {

    public PermissionAdapter(List<PermissionBean> list) {
        super(list);
    }


    @Override
    protected void bindDataToItemView(IndexViewHolder indexViewHolder, PermissionBean item) {

    }

    @Override
    public IndexViewHolder onCreateViewHolder(ViewGroup viewGroup, int type) {

        return new IndexViewHolder(inflateItemView(viewGroup, R.layout.permission_dialog_item));

    }

    public class IndexViewHolder extends BaseRecyclerViewAdapter.SparseArrayViewHolder {
        public IndexViewHolder(View itemView) {
            super(itemView);
        }
    }

    public void notifyItem(String name, boolean isSelect) {
        ArrayList<PermissionBean> strings = (ArrayList<PermissionBean>) super.mList;
        if (strings != null) {
            int size = strings.size();
            for (int it = 0; it < size; it++) {
                if (strings.get(it).getType_name() != null) {
                    if (strings.get(it).getType_name().equals(name)) {
                        strings.get(it).setSelect(true);
                    } else {
                        strings.get(it).setSelect(false);
                    }
                }
            }
        }


        super.addList(strings);

    }
}
